var eay = document.querySelectorAll(".eay");
var iptPas = document.querySelectorAll(".me-password");
var iptTxt = document.querySelector(".me-user")
var btn = document.querySelector(".btn");
var chek = document.querySelector(".chek");
var meIpt = document.querySelector(".me-phone");
var verification = document.querySelector(".me-verification");
var frame = document.querySelector("#frame");
var load = document.querySelector(".load");
var me = document.querySelector(".me");

/*最上方实时更新的时间*/
window.onload=function(){
    //每1秒刷新时间
	createCode(4);
  	setInterval("NowTime()",1000);
}
function NowTime(){
	var time = document.querySelector(".top-time");
	var myDate = new Date();
	var h=myDate.getHours();
	var m=myDate.getMinutes();
    h=check(h);
    m=check(m);
	time.innerText = h+":"+m;

}
function check(i){
    var num;
    i<10?num="0"+i:num=i;
    return num;
}

/*密码第一个的眼睛和显示*/
function eay1(){
	if(iptPas[0].type == "password"){
		iptPas[0].type = "text";
		eay[0].classList.add("eye_line");
	}else if(iptPas[0].type == "text"){
		iptPas[0].type = "password";
		eay[0].classList.remove("eye_line");
	}
}
/*密码第二个的眼睛和显示*/
function eay2(){
	if(iptPas[1].type == "password"){
		iptPas[1].type = "text";
		eay[1].classList.add("eye_line");
	}else if(iptPas[1].type = "text"){
		iptPas[1].type = "password";
		eay[1].classList.remove("eye_line");
	}
}

/*注册页面的点击按钮判断事件*/
function register(){
	btn.onclick=function(){
		if(iptTxt.value == ""){
			alert("请输入用户名")
		}else if(iptPas[0].value != iptPas[1].value){
			alert("请输入相同的密码")
		}else if(iptPas[0].value.length > 16 || iptPas[0].value.length < 5){
	        alert("密码不能小于5位或超出16位")
	    }else if(iptPas[1].value.length > 16 || iptPas[1].value.length < 5){
	        alert("密码不能小于5位或超出16位")
	    }else if(meIpt.value.length != 11){
	    	alert("请输入正确的手机号")
	    }else if(verification.value != code){
	    	alert("请输入正确的验证码")
	    }else if(chek.checked  != true){
	        alert("请同意协议")
	    }else{
	    	frame.style.display = 'block'
	    }
	}
}
// register();

/*验证码*/
var code = "";
function createCode(length) {
    var codeLength = parseInt(length); //验证码的长度
    var checkCode = document.getElementsByClassName("vae-txt")[0];
    ////所有候选组成验证码的字符，当然也可以用中文的
    var codeChars = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    //循环组成验证码的字符串
    for (var i = 0; i < codeLength; i++){
        var charNum = Math.floor(Math.random() * 35);
        code += codeChars[charNum];
    }
    if (checkCode){
        //为验证码区域添加样式名
        checkCode.className = "code";
        //将生成验证码赋值到显示区
        checkCode.innerHTML = code;
    }
}

/*登陆界面*/
function Sign(){
	btn.onclick=function(){
		if(iptTxt.value != "纵横帮"){
			alert("请输入正确的账号")
		}else if(iptPas[0].value != "666666"){
			alert("请输入正确的密码")
		}else if (iptPas[0].value == "666666" || iptTxt.value == "纵横帮") {
			load.style.height = '2.75rem';
			setTimeout("this.location.href = '" + "index.html" + "'",1000);
		}
	}
	iptTxt.onblur=function(){
		if(iptTxt.value == "纵横帮"){
			me.src = "images/me-my.png";
			me.style.padding = '0';
			me.style.width = '6.75rem'
		}else{
			me.src = "images/me.png";
			me.style.padding = '1rem';
			me.style.width = '4.75rem'
		}
	}
}
// Sign();

/*注册页面判断*/
/*手机号要输入十一位，验证码输入六位。
  只有当验证码是666666的时候才会成功
*/
var newIpt = document.querySelectorAll(".me-ipt");
function pas(){
	btn.onclick=function () {
	    if(newIpt[0].value.length != 11){
	        alert("请输入正确的手机号");
	    }else if(newIpt[1].value != "666666"){
	    	alert("验证码错误");
	    }else if(newIpt[1].value == "666666"){
			alert("验证码正确")
			newIpt[2].href = "alterPass.html";
	    }
	}
}


// pas();



/*编辑资料*/
